#ifndef SAVEFILETHREAD_H
#define SAVEFILETHREAD_H

#include <QObject>
#include <QFile>
#include <QDir>
#include <QDateTime>

#include "head.h"
#include "savesettings.h"
#include "myconfig.h"

class SaveFileThread : public QObject {
    Q_OBJECT
public:
    explicit SaveFileThread(QObject* parent = nullptr);

    void setInfo(QString targetIP, QString desc, quint16 port, QString fileSavePath); //设置网络信息

    void setParam(const SettingsData &settingsData);    //设置保存模式的参数

    void working(const QString ip, const quint16 port, const QByteArray arr); //保存函数

    int getFileCount();// 获取当前文件夹中的文件数量

    void deleteFiles(int numToDelete);// 删除旧文件
private:
    QString m_targetIP = "";
    QString m_desc = "";
    quint16 m_port = 0;

    quint64 m_maxFileSize;            // 修改阈值时, m_currFileSize 默认值 要大于 m_maxFileSize
    quint64 m_currFileSize;           // 默认大于 m_maxFileSize,  一进函数就执行打开文件操作

    QFile m_file;

    int m_saveMaxNum;
    int m_deleteWayIndex;

    quint64 m_splitWayValueBytes;

    QString m_fileSavePath;
};

#endif // SAVEFILETHREAD_H
